import Vue from "vue"

var isVue2 = true

var isVue3 = false

var Vue2 = Vue

var warn = Vue.util.warn

function install() { }

export function createApp(rootComponent, rootProps) {
    var vm

    var provide = {}

    var app = {
        config: Vue.config,

        use: Vue.use.bind(Vue),

        mixin: Vue.mixin.bind(Vue),

        component: Vue.component.bind(Vue),

        provide: function (key, value) {
            provide[key] = value
            return this
        },

        directive: function (name, dir) {
            if (dir) {
                Vue.directive(name, dir)
                return app
            } else {
                return Vue.directive(name)
            }
        },

        mount: function (el, hydrating) {
            if (!vm) {
                vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) }))
                vm.$mount(el, hydrating)
                return vm
            } else {
                return vm
            }
        },

        unmount: function () {
            if (vm) {
                vm.$destroy()
                vm = undefined
            }
        },
    }
    return app
}

export { Vue, Vue2, isVue2, isVue3, install, warn }

export * from 'vue'
